"""
文件 VO
"""

from config import settings
from models import (
    VOBase,
    VOPage,
)
from models.other import ProcessBase
from utils.data_utils.special import ObjectIdStr
from utils.mock_utils import Demo
from utils.validator_utils.pydantic_validator.field import (
    CharField,
    IntegerField,
    NormalField,
)


class FileListVO(VOBase):
    """ 文件 | 列表 | VO """

    file_id: ObjectIdStr = CharField(..., title="文件 ID（ObjectId 字符串）", examples=[Demo.id])

    create_time: str = CharField(..., title="创建时间", min_length=19, max_length=19, examples=[Demo.date_str])
    content_type: str = CharField(..., title="文件类型", max_length=128, examples=[Demo.img_content_type])
    filename: str = CharField(..., title="自定义文件名", max_length=64, examples=[Demo.img_name])
    is_public: bool = NormalField(..., title="是否公开")
    raw_filename: str = CharField(..., title="原始文件名", max_length=512, examples=[Demo.img_fullname])
    size: int = IntegerField(..., title="文件大小（Bytes）", min_value=1, max_value=settings.LIMIT.MAX_FILE_SIZE)


class FileDetailVO(FileListVO):
    """ 文件 | 详情 | VO """

    suffix: str = CharField(..., title="文件后缀", max_length=16, examples=["jpg"])
    update_time: str = CharField(..., title="更新时间", min_length=19, max_length=19, examples=[Demo.dt_str])
    user_id: ObjectIdStr | None = CharField(..., title="用户 ID", examples=[Demo.id])


class FileBatchDownloadVO(ProcessBase):
    """ 文件 | 批量下载 | VO """


class FileListPage(VOPage[FileListVO]):
    """ 文件 | 列表 | 分页 """
